Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!!!FEATURE: Add virtual object configurations for framework loggers #2134

Merged
merged 19 commits into from Nov 7, 2020

Conversation

albe
Copy link
Member

@albe albe commented Sep 18, 2020

With this, it is possible to inject the Flow systemLogger, securityLogger, sqlLogger and i18nLogger via the virtual objects Neos.Flow:SystemLogger, Neos.Flow:SecurityLogger, Neos.Flow:SqlLogger and Neos.Flow:I18nLogger respectively.

/**
 * @Flow\Inject(name="Neos.Flow:SystemLogger")
 * @var LoggerInterface
 */
protected $systemLogger;

Note: This also removes the deprecated PsrSecurityLoggerInterface and PsrSystemLoggerInterface, which should be replaced by injections like above.

Resolves #2125

Copy link
Contributor

@sorenmalling sorenmalling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by reading - format is as we discussed in original PR

I'm not a good writer at all. But I'm a believer of iterative incremental improvement.
@albe
Copy link
Member Author

albe commented Sep 18, 2020

Added some docs for the logging part of Flow that was still missing. It's very basic still, but any help is highly welcome!

@albe albe changed the title FEATURE: Add virtual object configurations for system and security logger !!!FEATURE: Add virtual object configurations for system and security logger Sep 18, 2020
@albe
Copy link
Member Author

albe commented Sep 18, 2020

Q: Is a code migration possible that replaces

* @var .*PsrSecurityLoggerInterface
* @Flow\Inject

and

* @Flow\Inject
* @var .*PsrSecurityLoggerInterface

with the above? i.e. multi-line replacements?

@albe
Copy link
Member Author

albe commented Sep 18, 2020

TODO:

  • Maybe add a code-example for logging an exception via ThrowableStorage?

@sorenmalling
Copy link
Contributor

TODO: Maybe add a code-example for logging an exception via ThrowableStorage?

That will be a great addition to the docs 🤩

@albe
Copy link
Member Author

albe commented Sep 19, 2020

cc @lorenzulrich - maybe you have something to add/improve? I'm really bad at (technical) writing in a way that it is user-friendly/understandable

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thanks for pushing this topic!

@albe
Copy link
Member Author

albe commented Sep 19, 2020

Also replaced nearly all of the Objects.yaml logger injections with an @Flow\Inject(name="Neos.Flow:*Logger") annotation. CacheManager still needs the setter injection because it's instanciated before the injection is available and two other places still use other class injections via Objects.yaml, so not sure it really helps getting rid of the logger part only there.

@albe albe changed the title !!!FEATURE: Add virtual object configurations for system and security logger !!!FEATURE: Add virtual object configurations for framework loggers Sep 19, 2020
Copy link
Member

@daniellienert daniellienert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, apart from that logger change.

Neos.Flow/Classes/Session/Aspect/LoggingAspect.php Outdated Show resolved Hide resolved
Copy link
Member

@daniellienert daniellienert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I don't see an improvement for the case of the system logger, despite of having "configuration over convention" (🤔). But as long as the LoggerInterface still defaults SystemLogger implementation, I don't want to block this.

@daniellienert daniellienert dismissed their stale review September 19, 2020 20:16

Personally I don't see an improvement for the case of the system logger, despite of having "configuration over convention" (🤔). But as long as the LoggerInterface still defaults SystemLogger implementation, I don't want to block this.

@albe
Copy link
Member Author

albe commented Sep 20, 2020

Personally I don't see an improvement for the case of the system logger

Yeah, it's not an "improvement" for that case. But this is more about making the injection of any logger straight forward through a single documented method. More about consistency than anything else.

Copy link
Member

@bwaidelich bwaidelich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good (by reading)
Thanks a lot for taking care!

@albe
Copy link
Member Author

albe commented Nov 7, 2020

I reverted the removal of the injectLogger() methods for now, then replaced the needless cases in tests with $this->inject().
Would merge this now once tests pass again.

Edit: Missed a few places where the logger can be injected via annotation safely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make injecting the framework loggers more straightforward and document it
4 participants